Reference for Wiring version 0027+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.
Name |
pulseIn() |
Examples |
int inpin = 0;
int val = 0;
void setup() {
pinMode(inpin, INPUT);
}
void loop() {
val = pulseIn(inpin, HIGH);
} |
Description |
The pulseIn() method returns the length in microseconds on a digital input pin for a short period of time from 10 milliseconds to 3 minutes. It can be used to read sensors that return a pulse train like some accelerometers or rangers. The user can specify the counting on HIGH or LOW transitions. The pulseIn command stops all activity while executing. A timeout of 1 second (1000000 microseconds) prevents the command to wait forever. A specific timeout in microseconds can also be specified. |
Syntax |
pulseIn(pin,transition)
pulseIn(pin,transition,timeout) |
Parameters |
pin |
int: the pin used for reading the pulse |
transition |
HIGH or LOW |
timeout |
int: a timeout value in microseconds |
|
Returns |
int |
Usage |
Application |
Updated on September 16, 2010 09:16:41pm PDT